<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String contextPath = request.getContextPath(); %>
<%@page import="common.*" %>
<%
	request.setCharacterEncoding("UTF-8");
	Customer user = (Customer)session.getAttribute("user");
	String category = null;
	String itemname = null;
	Item item = (Item)request.getAttribute("item");
	if(item == null)
	{
		String code = (String)request.getParameter("code");
		item = Item.find_by_code(code);
	}
	category = request.getParameter("cg");
	if(category == null || category.length() ==0 || category.equals("null"))
	{ category = item.getCategory_code(); }
	try
	{
		itemname = new String (request.getParameter("in").getBytes("UTF-8"));
	}
	catch(NullPointerException e)
	{
		itemname = item.getName();
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<%= contextPath %>/css/style.css" rel="stylesheet" type="text/css" />
		<link href="<%= contextPath %>/css/sidemenu.css" rel="stylesheet" type="text/css" />
		<link href="<%= contextPath %>/css/itemInfo.css" rel="stylesheet" type="text/css" />
		
		<title>商品</title>
	</head>
	<body>
		<div id="wrapper">
			<div id="sidemenu"">
				<jsp:include page="sidemenu.jsp" flush="true"/>
			</div>
			<div id="contents">
				<div id="header"></div>
				<div id="style">
					<div id="image">
						<img src="../res/<%= item.getImage() %>" width="235px" height="235px" />
					</div>
					<div id="name">
						商品名　：<br />
						規格　：<br />
						商品コード　：<br />
						カテゴリ　：<br />
						売単価　：<br />
						在庫数　：<br />
					</div>
					<div id="item">
						<%= item.getName() %><br />
						<%= item.getSize() %><br />
						<%= item.getCode() %><br />
						<%= item.getCategoryName() %><br />
						<%= item.getPrice() %>円<br />
						<%= item.getStock() %><br />
					</div>
					<div class="clear"></div>
				</div>
				<div id="info">
					商品説明　：<br />
					<%= item.getInfo() %>
				</div>
				<div>
					<div id="return">
						<a href="<%= contextPath %>/customer/itemList.jsp?in=<%= itemname %>&cg=<%= category %>" id="back">戻る</a>
					</div>
					<div id="order">
						<form action="../orderCus/OrderRegistServlet">
							<div style="text-align: right">
								個数<input type="text" name="orders" size="2" id="orders" />個
							</div>
							<div id="cart">
								<input type="hidden" name="code" value="<%= item.getCode() %>" />
								<input type="hidden" name="in" value="<%= itemname %>" />								
								<input type="hidden" name="cg" value="<%= category %>" />
								<input type="submit" value="カートに入れる" />
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
